<?php
  class blog_controller{
    var $config;
    var $model;
    function __construct($config){
      $this->config = $config;
      $this->model  = new blog_model($this->config['data_dir']);
    }
    function action_default () {
      return $this->action_index();
    }
    function action_index () {
      //echo 'index';
      //print_r(filemanager::treefilelist($this->config['data_dir']));
      preg_match_all('/'.$this->config['route']['index'].'/', $_GET['uri'], $out);
      print_r($out);
      
      $uri = $out[1][0];
      $page = $out[3][0];
      
      $posts = $this->model->get_post_list($uri, $page);
      view::display('index',array(
        'posts' => $posts,
      ));
      
    }
    function action_show () {
      $blog = $this->model->find($this->config['data_dir'] . filemanager::ext_replace('html', 'blog', $_GET['uri']));
      
      view::display('show',array(
        'blog' => $blog
      ));
    }
  }